home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Applications / Charting Coach v1.5 / Charting Coach v1.dxr / 00510.ls < prev    next >
Encoding:
Text File  |  1996-04-08  |  17.4 KB  |  595 lines

  1. on checkChanges
  2.   global advice, basis, stamp, dayNo, bioInfo, PeakDayNo, currentCycleNo, userNo, cycleNo, wantsToViewCycles, previousPeak
  3.   if getOne(stamp, 10) <> 0 then
  4.     setAt(stamp, getOne(stamp, 10), 3)
  5.   end if
  6.   set advice to []
  7.   set basis to []
  8.   repeat with i = 1 to count(stamp)
  9.     set dayNo to i
  10.     if checkLogic2() then
  11.       if max(bioInfo) = 14 then
  12.         getConceiveAdvice()
  13.       else
  14.         getAbstainAdvice()
  15.       end if
  16.       next repeat
  17.     end if
  18.     beep(2)
  19.     go("monthly")
  20.     makeCorrection()
  21.     cursor(0)
  22.     exit
  23.   end repeat
  24.   set P to getOne(stamp, 10)
  25.   if P > 0 then
  26.     set P to P + 1
  27.     repeat with i = P to count(stamp)
  28.       if ((getAt(stamp, i) = 3) or (getAt(stamp, i) = 10)) and (getOne(stamp, 10) > 0) then
  29.         set previousPeak to P
  30.         set PeakDayNo to 0
  31.         setAt(stamp, P, 3)
  32.       end if
  33.     end repeat
  34.   end if
  35.   killcorrection()
  36.   writecycleinfo()
  37.   puppetVisible(13, 48, 1)
  38.   puppetStatus(11, 48, 0)
  39.   if wantsToViewCycles = 0 then
  40.     if currentCycleNo <> getAt(cycleNo, userNo) then
  41.       set currentCycleNo to getAt(cycleNo, userNo)
  42.       readCycleInfo()
  43.     end if
  44.     go("removeimage")
  45.     prepfrontpage()
  46.   else
  47.     go("removeimage")
  48.     go("cycle list")
  49.     cursor(0)
  50.   end if
  51. end
  52.  
  53. on upToNow10 dayNum
  54.   repeat with i = 1 to dayNum
  55.     if getAt(stamp, i) = 10 then
  56.       return 1
  57.     end if
  58.   end repeat
  59.   return 0
  60. end
  61.  
  62. on resetpeak
  63.   global PeakDayNo, stamp, previousPeak
  64.   if getOne(stamp, 10) > 0 then
  65.     setAt(stamp, getOne(stamp, 10), 3)
  66.   end if
  67.   set previousPeak to PeakDayNo
  68.   set PeakDayNo to 0
  69. end
  70.  
  71. on resetAdvice
  72.   global advice, basis, dayNo, stamp, PeakDayNo, previousPeak, forewarned
  73.   set advice to []
  74.   set basis to []
  75.   set PeakDayNo to 0
  76.   set forewarned to 0
  77.   repeat with i = 1 to count(stamp)
  78.     set dayNo to i
  79.     if max(bioInfo) = 14 then
  80.       getConceiveAdvice()
  81.       next repeat
  82.     end if
  83.     getAbstainAdvice()
  84.   end repeat
  85. end
  86.  
  87. on getOnlyRedPrevious
  88.   global stamp, dayNo
  89.   if dayNo < 1 then
  90.     return 1
  91.   end if
  92.   if getAt(stamp, 1) > 1 then
  93.     return 0
  94.   end if
  95.   repeat with i = 1 to dayNo - 1
  96.     if getAt(stamp, i) > 2 then
  97.       return 0
  98.     end if
  99.   end repeat
  100.   set countbrown to 0
  101.   repeat with i = 1 to dayNo - 1
  102.     if getAt(stamp, i) = 2 then
  103.       set countbrown to countbrown + 1
  104.       if countbrown > 1 then
  105.         return 0
  106.       end if
  107.       next repeat
  108.     end if
  109.     set countbrown to 0
  110.   end repeat
  111.   return 1
  112. end
  113.  
  114. on getOnlyRedPrevious2 dayNum
  115.   if dayNum < 1 then
  116.     return 1
  117.   end if
  118.   repeat with i = 1 to dayNum
  119.     if getAt(stamp, i) > 2 then
  120.       return 0
  121.     end if
  122.   end repeat
  123.   set countbrown to 0
  124.   repeat with i = 1 to dayNum
  125.     if getAt(stamp, i) = 2 then
  126.       set countbrown to countbrown + 1
  127.       if countbrown > 2 then
  128.         return 0
  129.       end if
  130.       next repeat
  131.     end if
  132.     set countbrown to 0
  133.   end repeat
  134.   return 1
  135. end
  136.  
  137. on getAnovulatory
  138.   global stamp, previousPeak
  139.   if (getOne(stamp, 10) > 0) or (previousPeak > 0) then
  140.     killAnovul()
  141.     return 0
  142.   else
  143.     set x to getOne(stamp, 3)
  144.     if x > 0 then
  145.       set countFromWhite to x
  146.     else
  147.       set countFromWhite to 1
  148.     end if
  149.     repeat with i = countFromWhite to count(stamp)
  150.       if getAt(stamp, i) = 6 then
  151.         setAnovul()
  152.         return 1
  153.       end if
  154.     end repeat
  155.   end if
  156.   if getOne(bioInfo, 13) > 0 then
  157.     return 1
  158.   else
  159.     return 0
  160.   end if
  161. end
  162.  
  163. on killAnovul
  164.   global bioInfo
  165.   if getOne(bioInfo, 13) > 0 then
  166.     deleteAt(bioInfo, getOne(bioInfo, 13))
  167.   end if
  168. end
  169.  
  170. on setAnovul
  171.   global bioInfo
  172.   if getOne(bioInfo, 13) = 0 then
  173.     append(bioInfo, 13)
  174.   end if
  175.   if getOne(bioInfo, 9) > 0 then
  176.     deleteAt(bioInfo, getOne(bioInfo, 9))
  177.   end if
  178.   if getOne(bioInfo, 10) > 0 then
  179.     deleteAt(bioInfo, getOne(bioInfo, 10))
  180.   end if
  181.   if getOne(bioInfo, 11) > 0 then
  182.     deleteAt(bioInfo, getOne(bioInfo, 11))
  183.   end if
  184. end
  185.  
  186. on start3YellowBabies
  187.   global PeakDayNo, previousPeak
  188.   set dayNum to count(stamp)
  189.   if (getAt(stamp, 1) = 4) and (PeakDayNo = 0) and (previousPeak = 0) then
  190.     return 1
  191.   end if
  192.   return 0
  193. end
  194.  
  195. on inspectbasis basisNo
  196.   if getOne(goodbasisList, basisNo) then
  197.     return 1
  198.   else
  199.     return 0
  200.   end if
  201. end
  202.  
  203. on violatedRule
  204.   global relations, advice, dayNo
  205.   set dayNum to dayNo
  206.   if dayNum < 2 then
  207.     return 0
  208.   end if
  209.   if getAt(relations, dayNum - 1) <> 4 then
  210.     set lookadvice to getAt(advice, dayNum - 1)
  211.     if lookadvice > 1000 then
  212.       set lookadvice to lookadvice - 1000
  213.     end if
  214.     if (lookadvice = 101) or (lookadvice = 104) or ((lookadvice > 106) and (lookadvice < 110)) then
  215.       return 1
  216.     else
  217.       if (lookadvice = 102) and (getAt(relations, dayNum - 1) <> 2) then
  218.         return 1
  219.       else
  220.         return 0
  221.       end if
  222.     end if
  223.   else
  224.     return 0
  225.   end if
  226. end
  227.  
  228. on alertviolatedRule
  229.   global relations, advice, dayNo
  230.   set dayNum to dayNo
  231.   if dayNum < 1 then
  232.     return 0
  233.   end if
  234.   if getAt(relations, dayNum) <> 4 then
  235.     set lookadvice to getAt(advice, dayNum)
  236.     if lookadvice > 1000 then
  237.       set lookadvice to lookadvice - 1000
  238.     end if
  239.     if (lookadvice = 101) or (lookadvice = 104) or ((lookadvice > 106) and (lookadvice < 110)) then
  240.       return 1
  241.     else
  242.       if (lookadvice = 102) and (getAt(relations, dayNum) <> 2) then
  243.         return 1
  244.       else
  245.         return 0
  246.       end if
  247.     end if
  248.   else
  249.     return 0
  250.   end if
  251. end
  252.  
  253. on anyFertileDay
  254.   global mucus
  255.   set last to count(mucus)
  256.   repeat with i = 1 to last
  257.     if (getAt(mucus, i) < 7) and (getAt(mucus, i) > 1) then
  258.       return 1
  259.     end if
  260.   end repeat
  261. end
  262.  
  263. on checkLogicRed
  264.   global stamp, mucus
  265.   if getOnlyRedPrevious() = 0 then
  266.     cursor(0)
  267.     go("StartNewCycle")
  268.     cursor(0)
  269.   else
  270.     append(relations, 0)
  271.     append(stamp, 1)
  272.     append(mucus, 0)
  273.     showDays()
  274.     setupDayBook()
  275.     cursor(0)
  276.   end if
  277. end
  278.  
  279. on checkLogicBrown
  280.   global stamp, mucus, PeakDayNo
  281.   set dayNum to count(stamp)
  282.   if dayNum > 0 then
  283.     if ((PeakDayNo > 0) and ((dayNum - PeakDayNo) < 3)) or (getAt(stamp, dayNum) = 3) then
  284.       cursor(0)
  285.       set the visible of sprite 16 to 0
  286.       alert("If dry within three days after the presence of mucus or spotting, choose the Brown Baby Stamp.")
  287.       set the visible of sprite 16 to 1
  288.     else
  289.       append(relations, 0)
  290.       append(mucus, 0)
  291.       append(stamp, 2)
  292.       setupDayBook()
  293.       showDays()
  294.       cursor(0)
  295.     end if
  296.   else
  297.     append(relations, 0)
  298.     append(mucus, 0)
  299.     append(stamp, 2)
  300.     setupDayBook()
  301.     showDays()
  302.     cursor(0)
  303.   end if
  304. end
  305.  
  306. on checkLogicWhite
  307.   global PeakDayNo, stamp, forewarned, candidateStamp
  308.   if forewarned = 1 then
  309.     cursor(0)
  310.     alert("The Previous Peak will be removed.")
  311.     cursor(4)
  312.     set forewarned to 0
  313.     resetpeak()
  314.     set candidateStamp to 3
  315.     go("chart mucus")
  316.     cursor(0)
  317.   else
  318.     if getOne(stamp, 10) > 0 then
  319.       cursor(0)
  320.       if max(mucus) > 0 then
  321.         set forewarned to 1
  322.         set the visible of sprite 16 to 0
  323.         alert("     You have chosen the White Baby stamp but Peak Day was identified previously." & RETURN & "     If you have a milky white mucus, choose the Yellow Stamp. If you have a moist or lubricated sensation or a clear, stretchy mucus, choose the White Baby stamp again.")
  324.         set the visible of sprite 16 to 1
  325.       else
  326.         set candidateStamp to 3
  327.         go("chart mucus")
  328.         cursor(0)
  329.         set PeakDayNo to 0
  330.       end if
  331.     else
  332.       if PeakDayNo > 0 then
  333.         set PeakDayNo to 0
  334.       end if
  335.       set candidateStamp to 3
  336.       go("chart mucus")
  337.       cursor(0)
  338.     end if
  339.   end if
  340. end
  341.  
  342. on checklogicYellowBaby
  343.   global PeakDayNo, stamp, candidateStamp, mucus
  344.   set dayNum to count(stamp)
  345.   if dayNum > 0 then
  346.     if ((PeakDayNo > 0) and ((count(stamp) - PeakDayNo) > 2)) or ((PeakDayNo > 0) and ((count(stamp) - PeakDayNo) < 4) and ((PeakDayNo - getOne(stamp, 10)) > 3) and (getAt(stamp, count(stamp)) <> 3)) or ThreeBabies() then
  347.       cursor(0)
  348.       set the visible of sprite 16 to 0
  349.       alert("The Yellow Baby stamp should only be chosen for the three days after Peak Day. ")
  350.       set the visible of sprite 16 to 1
  351.     else
  352.       if (getAt(mucus, dayNum) < 7) and (getAt(mucus, dayNum) > 1) then
  353.         set candidateStamp to 4
  354.         go("askSensation")
  355.         cursor(0)
  356.       else
  357.         if (getAt(stamp, count(stamp)) = 2) or (getAt(stamp, count(stamp)) = 6) or getOnlyRedPrevious() or (not SomethingFertile() and (dayNum > 3)) then
  358.           cursor(0)
  359.           set the visible of sprite 16 to 0
  360.           alert("The Yellow Baby stamp should only be chosen for the three days after Peak Day.  At the onset of mucus, choose the White Baby Stamp.")
  361.           set the visible of sprite 16 to 1
  362.         else
  363.           set candidateStamp to 4
  364.           go("chart mucus")
  365.           cursor(0)
  366.         end if
  367.       end if
  368.     end if
  369.   else
  370.     set candidateStamp to 4
  371.     go("chart mucus")
  372.     cursor(0)
  373.   end if
  374. end
  375.  
  376. on ThreeBabies
  377.   set x to 0
  378.   set dayNum to count(stamp)
  379.   if dayNum < 3 then
  380.     return 0
  381.   end if
  382.   repeat with i = 0 to 2
  383.     if (getAt(stamp, dayNum - i) = 4) or (getAt(stamp, dayNum - i) = 5) or (getAt(stamp, dayNum - i) = 0) then
  384.       set x to x + 1
  385.       next repeat
  386.     end if
  387.     set x to 0
  388.   end repeat
  389.   if x > 2 then
  390.     return 1
  391.   else
  392.     return 0
  393.   end if
  394. end
  395.  
  396. on SomethingFertile
  397.   repeat with dayNum = 1 to count(stamp)
  398.     if (getAt(mucus, dayNum) < 7) and (getAt(mucus, dayNum) > 1) then
  399.       return 1
  400.     end if
  401.   end repeat
  402.   return 0
  403. end
  404.  
  405. on checkLogicBrownBaby
  406.   global PeakDayNo, stamp, candidateStamp, mucus
  407.   set dayNum to count(stamp)
  408.   if dayNum > 0 then
  409.     if ((PeakDayNo > 0) and ((count(stamp) - PeakDayNo) > 2)) or ThreeBabies() then
  410.       cursor(0)
  411.       set the visible of sprite 16 to 0
  412.       alert("The brown baby stamp should only be chosen for the three days after the presence of mucus or spotting.  When dry at other times use the brown stamp.")
  413.       set the visible of sprite 16 to 1
  414.     else
  415.       if (getAt(mucus, dayNum) < 7) and (getAt(mucus, dayNum) > 1) then
  416.         set candidateStamp to 5
  417.         go("askSensation")
  418.         cursor(0)
  419.       else
  420.         if (getAt(stamp, count(stamp)) = 2) or (getAt(stamp, count(stamp)) = 6) or ((getAt(stamp, count(stamp)) = 1) and getOnlyRedPrevious() and not getAnovulatory()) then
  421.           cursor(0)
  422.           set the visible of sprite 16 to 0
  423.           alert("The brown baby stamp should only be chosen for the three days after the presence of mucus or spotting.  When dry at other times use the brown stamp.")
  424.           set the visible of sprite 16 to 1
  425.         else
  426.           append(relations, 0)
  427.           append(mucus, 0)
  428.           append(stamp, 5)
  429.           showDays()
  430.           setupDayBook()
  431.         end if
  432.       end if
  433.       cursor(0)
  434.     end if
  435.   else
  436.     append(relations, 0)
  437.     append(mucus, 0)
  438.     append(stamp, 5)
  439.     showDays()
  440.     setupDayBook()
  441.   end if
  442. end
  443.  
  444. on checkLogicYellow
  445.   global stamp, mucus, PeakDayNo, candidateStamp, warnYellow
  446.   if count(stamp) = 0 then
  447.     if warnYellow = 1 then
  448.       set warnYellow to 0
  449.       set candidateStamp to 6
  450.       go("chart mucus")
  451.       cursor(0)
  452.       exit
  453.     else
  454.       set warnYellow to 1
  455.       cursor(0)
  456.       set the visible of sprite 16 to 0
  457.       alert("You may select the Yellow Stamp only if you've had two weeks of unchanging mucus. " & RETURN & RETURN & "If you've had two weeks of unchanging mucus, select the Yellow Stamp again.")
  458.       set the visible of sprite 16 to 1
  459.       exit
  460.     end if
  461.   end if
  462.   if getOne(stamp, 10) > 0 then
  463.     if (count(stamp) - PeakDayNo) < 3 then
  464.       cursor(0)
  465.       set the visible of sprite 16 to 0
  466.       alert("For the three days after Peak Day or Spotting, choose a Baby Stamp.")
  467.       set the visible of sprite 16 to 1
  468.     else
  469.       set candidateStamp to 6
  470.       go("chart mucus")
  471.       cursor(0)
  472.     end if
  473.   else
  474.     if ((PeakDayNo > 0) and ((count(stamp) - PeakDayNo) < 3)) or (getAt(stamp, count(stamp)) = 3) then
  475.       cursor(0)
  476.       set the visible of sprite 16 to 0
  477.       alert("For the three days after Peak type mucus or spotting, choose a Baby Stamp.")
  478.       set the visible of sprite 16 to 1
  479.     else
  480.       if getAnovulatory() or warnYellow then
  481.         set warnYellow to 0
  482.         set candidateStamp to 6
  483.         go("chart mucus")
  484.         cursor(0)
  485.       else
  486.         set warnYellow to 1
  487.         cursor(0)
  488.         set the visible of sprite 16 to 0
  489.         alert("You may select the Yellow Stamp only if you've had two weeks of unchanging mucus. " & RETURN & RETURN & "If you've had two weeks of unchanging mucus, select the Yellow Stamp again.")
  490.         set the visible of sprite 16 to 1
  491.       end if
  492.     end if
  493.   end if
  494. end
  495.  
  496. on checkLogic2
  497.   global PeakDayNo
  498.   if getOne(stamp, 1) > 0 then
  499.     set first to getOne(stamp, 1)
  500.     repeat with i = first to count(stamp) - 1
  501.       if (getAt(stamp, i) = 1) and (i > 2) then
  502.         if (getAt(stamp, i - 1) <> 1) and (getAt(stamp, i - 2) <> 1) then
  503.           if getAt(stamp, i + 1) = 2 then
  504.             put "ERROR: " & "On Day# " & i + 1 & ", the Brown Stamp was used.  If dry within three days after spotting, use the Brown Baby Stamp." into field "problem"
  505.             return 0
  506.             next repeat
  507.           end if
  508.           if getAt(stamp, i + 1) = 6 then
  509.             put "ERROR: " & "On Day# " & i + 1 & ", the Yellow Stamp was used.  If dry within three days after spotting, use the Brown Baby Stamp." into field "problem"
  510.             return 0
  511.           end if
  512.         end if
  513.       end if
  514.     end repeat
  515.   end if
  516.   if (getOne(stamp, 3) > 0) or (getOne(stamp, 10) > 0) then
  517.     repeat with i = 1 to count(stamp) - 1
  518.       if (getAt(mucus, i) < 7) and (getAt(mucus, i) > 1) and ((getAt(mucus, i + 1) > 7) or (getAt(mucus, i + 1) = 1)) and (getAt(stamp, i + 1) <> 4) then
  519.         put "ERROR: " & "On Day# " & i + 1 & ", there was a dramatic change in mucus.  The Yellow Baby Stamp should have been used unless there was a wet or lubricated sensation.  If there was a wet or lubricated sensation,  use the White Baby Stamp and the Sensation (raindrop) stamp." into field "problem"
  520.         return 0
  521.       end if
  522.       if (getAt(stamp, i) = 3) or (getAt(stamp, i) = 10) then
  523.         if getAt(stamp, i + 1) = 2 then
  524.           put "ERROR: " & "On Day# " & i + 1 & ", the Brown Stamp was used.  If dry within three days after the presence of mucus or spotting, use the Brown Baby Stamp." into field "problem"
  525.           return 0
  526.           next repeat
  527.         end if
  528.         if (getAt(stamp, i + 1) = 6) and (getAt(mucus, i) < 7) and (getAt(mucus, i) > 1) then
  529.           put "ERROR: " & "On Day# " & i + 1 & ", the Yellow Stamp was used.  Three days after the appearance of Peak Type mucus, use the Yellow Baby Stamp." into field "problem"
  530.           return 0
  531.           next repeat
  532.         end if
  533.         if (i + 2) < count(stamp) then
  534.           if getAt(stamp, i + 2) = 2 then
  535.             put "ERROR: " & "On Day# " & i + 2 & ", the Brown Stamp was used.  If dry within three days after the presence of mucus or spotting, use the Brown Baby Stamp." into field "problem"
  536.             return 0
  537.             next repeat
  538.           end if
  539.           if (getAt(stamp, i + 2) = 6) and (getAt(mucus, i) < 7) and (getAt(mucus, i) > 1) then
  540.             put "ERROR: " & "On Day# " & i + 1 & ", the Yellow Stamp was used.  Three days after the appearance of Peak Type mucus, use the Yellow Baby Stamp." into field "problem"
  541.             return 0
  542.             next repeat
  543.           end if
  544.           if (i + 3) < count(stamp) then
  545.             if getAt(stamp, i + 3) = 2 then
  546.               put "ERROR: " & "On Day# " & i + 3 & ", the Brown Stamp was used.  If dry within three days after the presence of mucus or spotting, use the Brown Baby Stamp." into field "problem"
  547.               return 0
  548.               next repeat
  549.             end if
  550.             if (getAt(stamp, i + 3) = 6) and (getAt(mucus, i) < 7) and (getAt(mucus, i) > 1) then
  551.               put "ERROR: " & "On Day# " & i + 1 & ", the Yellow Stamp was used.  Three days after the appearance of Peak Type mucus, use the Yellow Baby Stamp." into field "problem"
  552.               return 0
  553.             end if
  554.           end if
  555.         end if
  556.       end if
  557.     end repeat
  558.   end if
  559.   if (getOne(stamp, 4) > 0) or (getOne(stamp, 5) > 0) then
  560.     set x to 0
  561.     repeat with i = 1 to count(stamp)
  562.       if (getAt(stamp, i) = 4) or (getAt(stamp, i) = 5) then
  563.         if i > 1 then
  564.           if (getAt(stamp, i - 1) = 2) or (getAt(stamp, i - 1) = 6) then
  565.             if getAt(stamp, i) = 5 then
  566.               put "ERROR: " & "On Day# " & i & ", the Brown Baby Stamp was used.  Only use the Brown Baby Stamp the three days after the presence of mucus or spotting, at all other dry times use the Brown Stamp." into field "problem"
  567.               return 0
  568.             else
  569.               put "ERROR: " & "On Day# " & i & ", the Yellow Baby Stamp was used.  Only use the Yellow Baby Stamp the three days after Peak day or spotting." into field "problem"
  570.               return 0
  571.             end if
  572.           end if
  573.         end if
  574.         set x to x + 1
  575.         if x >= 4 then
  576.           if getAt(stamp, i) = 5 then
  577.             put "ERROR: " & "On Day# " & i & ", the Brown Baby Stamp was used.  If dry after Peak+3 days or more than three days after mucus or spotting, use the Brown Stamp." into field "problem"
  578.             return 0
  579.           else
  580.             put "ERROR: " & "On Day# " & i & ", the Yellow Baby Stamp was used.  If mucus is present after Peak+3 days or more than three days after spotting, use the Yellow Stamp or White Stamp." into field "problem"
  581.           end if
  582.           return 0
  583.         end if
  584.         next repeat
  585.       end if
  586.       set x to 0
  587.     end repeat
  588.     if not anyFertileDay() and (getOne(stamp, 4) > 0) then
  589.       put "ERROR: The Yellow Baby Stamp was used but there was no previous Peak type day." into field "problem"
  590.       return 0
  591.     end if
  592.   end if
  593.   return 1
  594. end
  595.